package com.woniuxy.controller;

import com.woniuxy.entity.SysTeam;
import com.woniuxy.service.SysTeamOrganizationService;
import com.woniuxy.util.ResponseUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 系统团队组织控制器
 * 处理系统团队组织相关的HTTP请求
 */
@RestController
@RequestMapping("/sysTeamOrganization")
public class SysTeamOrganizationController {
    @Resource
    private SysTeamOrganizationService sysTeamOrganizationService;
    /**
     * 根据医生ID、角色、组织ID和团队名称查询系统团队
     * @param doctorId 医生ID
     * @param role 角色
     * @param orgId 组织ID（可选）
     * @param teamName 团队名称（可选）
     * @return 返回符合条件的系统团队信息
     */
    @GetMapping
    public ResponseUtil selectSysTeam(@RequestParam Integer doctorId,
                                    @RequestParam Integer role,
                                    @RequestParam(required = false) Integer orgId,
                                    @RequestParam(required = false) String teamName) {
        return sysTeamOrganizationService.findSysTeam(doctorId,role,orgId,teamName);
    }

    /**
     * 根据机构ID查询所有团队
     * @param orgId 机构ID
     * @return 返回该机构的所有团队信息
     */
    @GetMapping("/org/{orgId}")
    public ResponseUtil findAllByOrgId(@PathVariable Integer orgId) {
        return sysTeamOrganizationService.findAllByOrgId(orgId);
    }

    @GetMapping("/{teamId}")
    public ResponseUtil findOrgByTeamId(@PathVariable Integer teamId) {
        return sysTeamOrganizationService.findOrgByTeamId(teamId);
    }
}
